package com.code.zjm.binder.demo.entity;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.List;

/**
 * Created by ZJM on 2017/3/16.
 */

public class Teacher implements Parcelable {
    private int teacherId;
    private String name;
    private List<Student> students;

    /**
     * 空构造器
     */
    public Teacher() {
    }

    /**
     * 初始化参数构造器
     *
     * @param teacherId
     * @param name
     * @param students
     */
    public Teacher(int teacherId, String name, List<Student> students) {
        this.teacherId = teacherId;
        this.name = name;
        this.students = students;
    }

    /**
     *
     * @param in
     */
    protected Teacher(Parcel in) {
        teacherId = in.readInt();
        name = in.readString();
        students = in.createTypedArrayList(Student.CREATOR);
    }


    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(teacherId);
        dest.writeString(name);
        dest.writeTypedList(students);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<Teacher> CREATOR = new Creator<Teacher>() {
        @Override
        public Teacher createFromParcel(Parcel in) {
            return new Teacher(in);
        }

        @Override
        public Teacher[] newArray(int size) {
            return new Teacher[size];
        }
    };

    public long getTeacherId() {
        return teacherId;
    }

    public void setTeacherId(int teacherId) {
        this.teacherId = teacherId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Student> getStudents() {
        return students;
    }

    public void setStudents(List<Student> students) {
        this.students = students;
    }

    @Override
    public String toString() {
        return getTeacherId() + "：" + getName();
    }


}
